from pydantic import BaseModel
from typing import Optional
from datetime import datetime

# 案例基础模型
class CaseBase(BaseModel):
    title: str
    description: str
    solution: str
    category: str

# 案例创建模型
class CaseCreate(CaseBase):
    keywords: Optional[str] = None
    approved: Optional[bool] = False

# 案例更新模型
class CaseUpdate(BaseModel):
    title: Optional[str] = None
    description: Optional[str] = None
    solution: Optional[str] = None
    keywords: Optional[str] = None
    category: Optional[str] = None
    approved: Optional[bool] = None

# 案例数据库模型
class CaseInDB(CaseBase):
    id: int
    keywords: Optional[str] = None
    created_by: int
    approved: bool
    created_at: datetime
    updated_at: datetime

    class Config:
        orm_mode = True

# 案例响应模型
class CaseResponse(CaseInDB):
    pass

# 案例搜索模型
class CaseSearch(BaseModel):
    query: str
    category: Optional[str] = None